home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3bthreadwidget.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  1.7 KB  |  79 lines

  1. /* 
  2.  *
  3.  * $Id: k3bthreadwidget.h 619556 2007-01-03 17:38:12Z trueg $
  4.  * Copyright (C) 2005 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16. #ifndef _K3B_THREAD_WIDGET_H_
  17. #define _K3B_THREAD_WIDGET_H_
  18.  
  19. #include <qobject.h>
  20. #include <qintdict.h>
  21.  
  22.  
  23. class QCustomEvent;
  24. namespace K3bDevice {
  25.   class Device;
  26. }
  27.  
  28. /**
  29.  * This class allows a thread other than the GUI thread to perform simple GUI
  30.  * operations. Mainly creating some simple K3b Dialogs like Device selection.
  31.  *
  32.  * Since the calling thread cannot create the K3bThreadWidget by himself there exists
  33.  * exactly one instance created by K3bCore which is used by all threads.
  34.  */
  35. class K3bThreadWidget : public QObject
  36. {
  37.   Q_OBJECT
  38.  
  39.  public:
  40.   ~K3bThreadWidget();
  41.  
  42.   static K3bThreadWidget* instance();
  43.  
  44.   /**
  45.    * Call this from a thread to show a device selection dialog.
  46.    */
  47.   static K3bDevice::Device* selectDevice( QWidget* parent, 
  48.                       const QString& text = QString::null );
  49.  
  50.  protected:
  51.   /**
  52.    * communication between the threads
  53.    */
  54.   void customEvent( QCustomEvent* );
  55.  
  56.  private:
  57.   /**
  58.    * used internally
  59.    */
  60.   class DeviceSelectionEvent;
  61.   class Data;
  62.  
  63.   K3bThreadWidget();
  64.  
  65.   /**
  66.    * Get unique id
  67.    */
  68.   int getNewId();
  69.   void clearId( int id );
  70.   Data* data( int id );
  71.  
  72.   int m_idCounter;
  73.   QIntDict<Data> m_dataMap;
  74.  
  75.   static K3bThreadWidget* s_instance;
  76. };
  77.  
  78. #endif
  79.